package formBean;

import java.util.ArrayList;
import java.util.List;

import org.mybeans.form.FormBean;

public class ChangePasswordForm extends FormBean{
	
	private String password;
	private String passwordConfirmation;
	/**
	 * @return the password
	 */
	public String getPassword() {
		return password;
	}
	/**
	 * @return the passwordConfirmation
	 */
	public String getPasswordConfirmation() {
		return passwordConfirmation;
	}
	/**
	 * @param password the password to set
	 */
	public void setPassword(String password) {
		this.password = password;
	}
	
	/**
	 * @param passwordConfirmation the passwordConfirmation to set
	 */
	public void setPasswordConfirmation(String passwordConfirmation) {
		this.passwordConfirmation = passwordConfirmation;
	}
	
	public List<String> getValidationErrors() {
		List<String> errors = new ArrayList<String>();

		if (password == null || password.length() == 0) {
			errors.add("Password is required");
		}else{
			if(password.contains(">") || password.contains("<") || password.contains("'") || password.contains("\\") || password.contains("/")){
				errors.add("confirmation password is not matching password");
			}
		}
		
		if (passwordConfirmation == null || passwordConfirmation.length() == 0) {
			errors.add("Password confirmation is required");
		}
		
		if(!password.equals(passwordConfirmation)){
			errors.add("confirmation password is not matching password");
		}
		
		return errors;
	}
}
